/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * UnitInfoPanel.java
 *
 * Created on 26/07/2011, 8:01:31 PM
 */
package deatax.display.gui;

import deatax.unit.UnitStack;

/**
 *
 * @author Pieman
 */
public class UnitInfoPanel extends ImagePanel {

    
    /** Creates new form UnitInfoPanel */
    public UnitInfoPanel() {
        initComponents();
    }

    public void setDetails(UnitStack stack) {
        setImage(stack.getType().getPortrait());
        lblUnitName.setForeground(stack.getOwner().getColor());
        lblUnitName.setText(stack.getType().getName());
        int tired = stack.getAmount() - stack.getFreshAmount();
        lblNum.setText(stack.getFreshAmount() + (tired > 0 ? (" (" + tired + ")") : ""));
        
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblUnitName = new javax.swing.JLabel();
        lblNum = new javax.swing.JLabel();

        setPreferredSize(new java.awt.Dimension(128, 64));

        lblUnitName.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblUnitName.setText("Unit Name");

        lblNum.setFont(lblNum.getFont().deriveFont(lblNum.getFont().getStyle() | java.awt.Font.BOLD, lblNum.getFont().getSize()+2));
        lblNum.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblNum.setText("Num");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lblNum, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE)
            .addComponent(lblUnitName, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(87, Short.MAX_VALUE)
                .addComponent(lblNum)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblUnitName)
                .addGap(6, 6, 6))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel lblNum;
    private javax.swing.JLabel lblUnitName;
    // End of variables declaration//GEN-END:variables
}
